package com.mflex.WHSmartWhouseAd.adapter;

import android.app.Activity;
import android.graphics.Color;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.mflex.WHSmartWhouseAd.R;
import com.mflex.WHSmartWhouseAd.model.QMSSamplingReturnPdaInfo;
import com.xuexiang.xutil.common.StringUtils;

import java.util.List;

public class QMSReturnBoxAdapter extends BaseAdapter {
    List<QMSSamplingReturnPdaInfo> items;
    Activity context;

    public QMSReturnBoxAdapter(Activity context, List<QMSSamplingReturnPdaInfo> items) {
        this.context = context;
        this.items = items;
    }

    @Override
    public int getCount() {
        return items.size();
    }

    @Override
    public Object getItem(int position) {
        return items.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        QMSSamplingReturnPdaInfo item = items.get(position);
        View view = convertView;
        view = context.getLayoutInflater().inflate(R.layout.item_qms_return_box, null);
        ((TextView) view.findViewById(R.id.txtVehicleNumber)).setText(item.getVehicleNumber());
        ((TextView) view.findViewById(R.id.txtReelId)).setText(item.getReelId());
        ((TextView) view.findViewById(R.id.txtTaskNo)).setText(item.getTaskNo());
        ((TextView) view.findViewById(R.id.txtMrart)).setText(item.getMPart());
        // 当前条变绿
       if(StringUtils.equals("1",item.getFlag())) {
           ((LinearLayout) view.findViewById(R.id.txtList)).setBackgroundColor(Color.GREEN);
       }


        return view;
    }
}